<template>
  <div>
    <van-nav-bar title="意见反馈" left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-form @submit="onSubmit">
      <div class="feedbox">
        <p class="p1">标题</p>
        <div class="feedtitle">
          <textarea name id cols="45" rows="2" placeholder="标题" v-model="feedbackTitle"></textarea>
        </div>
        <p>文本</p>
        <div class="feedtext">
          <textarea name id cols="45" rows="6" placeholder="文本" v-model="feedbackDetails"></textarea>
        </div>
      </div>
      <van-button round block type="primary" native-type="submit">发送</van-button>
    </van-form>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import { addfeeds } from "../model/userModel";
import { ref } from "vue";
let router = useRouter();
let feedbackTitle = ref("");
let feedbackDetails = ref("");
let onClickLeft = () => {
  router.push("/feedback");
};
let onSubmit = info => {
  addfeeds(
    {
      feedbackTitle: feedbackTitle.value,
      feedbackDetails: feedbackDetails.value
    },
    {
      Authorization: window.localStorage.getItem("token")
    }
  ).then(res => {
    console.log(res);
    router.push("/feedback");
  });
  // console.log("feedbackTitle", feedbackTitle.value);
  // console.log("feedbackDetails", feedbackDetails.value);
};
</script>

<style lang="scss">
.feedbox {
  width: 100%;
  .p1 {
    margin-top: 20px;
  }
  p {
    width: 100%;
    height: 26px;
    font-size: 14px;
    background-color: #eeeeee;
    margin-bottom: 10px;
    line-height: 26px;
  }
  .feedtitle {
    text-align: center;
  }
  .feedtext {
    text-align: center;
  }
  .van-button {
    width: 370px;
    border-radius: 10px;
    margin-left: 2px;
  }
}
</style>